var express = require('express');
var router = express.Router();
const { getOrder2, createOrder2, updateOrder2, deleteOrder2 } = require("../service/orderService")
/* GET users listing. */
router.get('/', async (req, res, next) => {
    /**
     * req.query
     * {
     *  查询条件
     * }
     */
    const inData = req.query;
    console.log("get请求", inData);
    const outData = await getOrder2(inData);
    res.send(outData);
});
router.post('/', async (req, res, next) => {
    /**
     * req.body
     * {
     *  新订单内容
     * }
     */
    const inData = req.body;
    console.log("post请求", inData);
    const outData = await createOrder2(inData);
    res.send(outData);
});
router.put('/', async (req, res, next) => {
    /**
     * req.body
     * {
     *  query:{_id:订单id}
     *  update:{新内容}
     * }
     */
    const inData = req.body;
    console.log("put请求", inData);
    const outData = await updateOrder2(inData);
    res.send(outData);
});
router.delete('/', async (req, res, next) => {
    /**
     * req.body
     * {
     *  _id:订单id
     * }
     */
    const inData = req.body;
    console.log("delete请求", inData);
    const outData = await deleteOrder2(inData);
    res.send(outData);
});

module.exports = router;